import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl:'./login.component.html'
  ,
  styleUrls: ['./login.component.css'],
})
export class LoginComponent implements OnInit {
  
  validateForm: FormGroup;
  constructor(private fb: FormBuilder,private router: Router,) {
    
  }


  _submitForm() {
    this.router.navigate(['./home']);//跳转到定义好的home 页面
    for (const i in this.validateForm.controls) {
      this.validateForm.controls[ i ].markAsDirty();
    }
    // this.loginService.login(2).subscribe(res=>console.log(res))
  }

  ngOnInit() {
    this.validateForm = this.fb.group({
      userName: [ null, [ Validators.required ] ],
      password: [ null, [ Validators.required ] ],
      remember: [ true ],
    });
  }
  
}
